package com.ssy.lingxi.platform.manage.repository;


import com.ssy.lingxi.platform.manage.entity.content.ContentInformation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ContentInformationRepository extends JpaRepository<ContentInformation, Long>, JpaSpecificationExecutor<ContentInformation> {

    Boolean existsBySortAndRecommendLabel(Integer sort, Integer recommendLabel);

    Boolean existsAllByFirstCategoryIdOrSecondCategoryIdOrThirdlyCategoryId(Long firstCategoryId, Long secondCategoryId, Long thirdlyCategoryId);

    Boolean existsAllByColumnId(Long columnId);

    List<ContentInformation> findAllByRecommendLabelAndStatus(Integer recommendLabel, Integer status, Sort sort);

    List<ContentInformation> findAllByRecommendLabelInAndStatus(List<Integer> recommendLabels, Integer status, Sort sort);

    List<ContentInformation> findAllByColumnIdAndStatus(Long columnId, Integer status, Sort sort);

    List<ContentInformation> findAllByColumnIdInAndStatusAndThirdlyCategoryId(List<Long> columnIdList, Integer status, Long thirdlyCategoryId);

    List<ContentInformation> findAllByColumnIdInAndStatus(List<Long> columnIdList, Integer status);

    List<ContentInformation> findAllByFirstCategoryIdOrSecondCategoryIdOrThirdlyCategoryId(Long firstCategoryId, Long secondCategoryId, Long thirdlyCategoryId);

    Page<ContentInformation> findAllByStatus(Integer status, Pageable pageable);

    Page<ContentInformation> findAllByStatusAndColumnId(Integer status, Long id, Pageable pageable);

    ContentInformation findBySortAndRecommendLabel(Integer sort, Integer recommendLabel);

    ContentInformation findByColumnIdAndRecommendLabel(Long columnId, Integer recommendLabel);

    Page<ContentInformation> findAllByStatusAndTitleContains(Integer status, String title, Pageable pageable);
}
